# 启动编译环境
FROM golang:1.18-alpine as bulder

# 配置编译环境
RUN go env -w GO111MODULE=on
RUN go env -w GOPROXY=https://goproxy.cn,direct

# 拷贝源代码到镜像
COPY . /go/src/coolcar/server

# 编译
WORKDIR /go/src/coolcar/server
RUN go install ./rental/...

# 这是运行镜像
FROM alpine:3.13
COPY --from=bulder /go/bin/rental /bin/rental
COPY ./config.yaml /bin/
COPY ./public.key /bin/

# 暴露端口
EXPOSE 8082

#  设置服务入口
WORKDIR /bin/
ENTRYPOINT [ "./rental" ]